<?php

/**
 * Familiar filter form base class.
 *
 * @package    sibi-salud
 * @subpackage filter
 * @author     SIBI <sibiud@gmail.com>
 */
abstract class BaseFamiliarFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'parentesco_id'      => new sfWidgetFormPropelChoice(array('model' => 'Parentesco', 'add_empty' => true)),
      'persona_usuario_id' => new sfWidgetFormPropelChoice(array('model' => 'Persona', 'add_empty' => true)),
      'persona_id'         => new sfWidgetFormPropelChoice(array('model' => 'Persona', 'add_empty' => true)),
      'acudiente'          => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'ocupacion'          => new sfWidgetFormFilterInput(),
      'escolaridad'        => new sfWidgetFormFilterInput(),
      'relacion'           => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'parentesco_id'      => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Parentesco', 'column' => 'id')),
      'persona_usuario_id' => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Persona', 'column' => 'id')),
      'persona_id'         => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Persona', 'column' => 'id')),
      'acudiente'          => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'ocupacion'          => new sfValidatorPass(array('required' => false)),
      'escolaridad'        => new sfValidatorPass(array('required' => false)),
      'relacion'           => new sfValidatorPass(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('familiar_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Familiar';
  }

  public function getFields()
  {
    return array(
      'parentesco_id'      => 'ForeignKey',
      'persona_usuario_id' => 'ForeignKey',
      'persona_id'         => 'ForeignKey',
      'acudiente'          => 'Boolean',
      'ocupacion'          => 'Text',
      'escolaridad'        => 'Text',
      'relacion'           => 'Text',
      'id'                 => 'Number',
    );
  }
}
